package router

import (
	"fmt"
	backendBusinessOpportunity "git.mycaigou.com/gfyx/micro-gfyx-api/http_server/backend_controller/business_opportunity"
	backendCommon "git.mycaigou.com/gfyx/micro-gfyx-api/http_server/backend_controller/common"
	backendMarket "git.mycaigou.com/gfyx/micro-gfyx-api/http_server/backend_controller/market"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/aggregation"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/base"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/business_opportunity"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/clue"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/common"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/job_center"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/market"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/rpa"
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller/subscription"
	"git.mycaigou.com/gfyx/micro-gfyx-api/infrastructure/di"
	"github.com/gin-gonic/gin"
)

// RegisterHealthRouters 检测
func RegisterHealthRouters(g *gin.RouterGroup) {
	new(controller.HealthController).RegisterRouter(g)
}

func RpaRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		rpaController *rpa.RpaController,
	) {
		rpaController.RegisterRouter(g)
	})

	fmt.Printf("RpaRegisterRouters-err: %+v", err)
}

func SiteRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		siteController *base.SiteController,
	) {
		siteController.RegisterRouter(g)
	})

	fmt.Printf("SiteRegisterRouters-err: %+v", err)
}

func BaseRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		orgController *base.OrgController,
		msgController *base.MsgController,
		roleController *base.RoleController,
		userNewController *base.UserNewController,
		menuController *base.MenuController,
		loginController *base.LoginNewController,
	) {
		orgController.RegisterRouter(g)
		msgController.RegisterRouter(g)
		roleController.RegisterRouter(g)
		userNewController.RegisterRouter(g)
		menuController.RegisterRouter(g)
		loginController.RegisterRouter(g)
	})

	fmt.Printf("BaseRegisterRouters-err: %+v", err)
}

func AggregationRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		statisticsController *aggregation.StatisticsController,
	) {
		statisticsController.RegisterRouter(g)
	})

	fmt.Printf("AggregationRegisterRouters-err: %+v", err)
}

func UserRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		userController *base.UserController,
	) {
		userController.RegisterRouter(g)

	})

	fmt.Printf("UserRegisterRouters err: %+v\n", err)
}

func LoginRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		loginController *base.LoginController,
	) {
		loginController.RegisterRouter(g)
	})

	fmt.Printf("LoginRegisterRouters err: %+v\n", err)
}

func OpptyFormRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		formController *business_opportunity.FormController) {
		formController.RegisterRouter(g)
	})

	fmt.Printf("OpptyFormRegisterRouters err: %+v\n", err)
}

func OpptyReportRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(reportController *clue.ReportController) {
		reportController.RegisterRouter(g)
	})

	fmt.Printf("OpptyReportRegisterRouters err: %+v\n", err)
}

func OpptyReportFollowRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(reportFollowController *business_opportunity.ReportFollowController) {
		reportFollowController.RegisterRouter(g)
	})

	fmt.Printf("OpptyReportRegisterRouters err: %+v\n", err)
}

func CommonRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		fileController *common.FileController,
		codeController *common.VerifyCodeController,
		reportController *common.DmpReportController,
		siteAnnouncementController *common.SiteAnnouncementController,
	) {
		fileController.RegisterRouter(g)
		codeController.RegisterRouter(g)
		reportController.RegisterRouter(g)
		siteAnnouncementController.RegisterRouter(g)
	})

	err = c.Invoke(func(
		commonController *common.CommonController,
	) {
		commonController.RegisterRouter(g)
	})

	fmt.Printf("CommonRegisterRouters err: %+v\n", err)
}

func ClueCustomerMonitorRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(ctl *clue.CustomerMonitorController) {
		ctl.RegisterRouter(g)
	})
	fmt.Printf("ClueCustomerMonitorRegisterRouters err: %+v\n", err)
}

func OptionRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(optionController *common.OptionController) {
		optionController.RegisterRouter(g)
	})
	fmt.Printf("OptionRegisterRouters err: %+v\n", err)
}

func ContactRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(contactController *business_opportunity.ContactController) {
		contactController.RegisterRouter(g)
	})
	fmt.Printf("ContactRegisterRouters err: %+v\n", err)
}

func ClueRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(ctc *clue.ClueManageController) {
		ctc.RegisterRouter(g)
	})
	fmt.Printf("ClueRegisterRouters err: %+v\n", err)
}

func CustomerRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(ctl *clue.CustomerManageController) {
		ctl.RegisterRouter(g)
	})
	fmt.Printf("CustomerRegisterRouters err: %+v\n", err)
}

func SubscriptionRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(ctc *subscription.SubscriptionController) {
		ctc.RegisterRouter(g)
	})
	fmt.Printf("SubscriptionRegisterRouters err: %+v\n", err)
}

func BusinessOpportunityRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		ctl *business_opportunity.CustomerController,
		orderCtl *business_opportunity.OrderController,
		projectCtl *business_opportunity.ProjectController,
		bidCtl *business_opportunity.BidController,
		customerGroupCtl *business_opportunity.CustomerGroupController,
		buildingCtl *business_opportunity.BuildingController,
		marketInsightCtl *business_opportunity.MarketInsightController,
		landCtl *business_opportunity.LandController,
		monitorController *business_opportunity.StrategicMonitorController,
	) {
		ctl.RegisterRouter(g)
		orderCtl.RegisterRouter(g)
		projectCtl.RegisterRouter(g)
		bidCtl.RegisterRouter(g)
		customerGroupCtl.RegisterRouter(g)
		buildingCtl.RegisterRouter(g)
		marketInsightCtl.RegisterRouter(g)
		landCtl.RegisterRouter(g)
		monitorController.RegisterRouter(g)

	})
	fmt.Printf("SubscriptionRegisterRouters err: %+v\n", err)
}

func OpenApiRegisterRouters(g *gin.RouterGroup) {
	_ = di.InjectInstance().Invoke(func(ctl *common.OpenApiController) {
		ctl.RegisterRouter(g)
	})
}

func MpRegisterRouters(g *gin.RouterGroup) {
	_ = di.InjectInstance().Invoke(func(ctl *common.MpController) {
		ctl.RegisterRouter(g)
	})
}

func OutboundCallbackRegisterRouter(g *gin.RouterGroup) {
	_ = di.InjectInstance().Invoke(func(ctl *market.ByCallBackController) {
		ctl.RegisterRouter(g)
	})
}

func OutboundRegisterRouter(g *gin.RouterGroup) {
	err := di.InjectInstance().Invoke(
		func(
			accountCtl *market.OutboundAccountController,
			ctl *market.OutboundCrowdController,
			taskCtl *market.OutboundTaskController,
		) {
			accountCtl.RegisterRouter(g)
			ctl.RegisterRouter(g)
			taskCtl.RegisterRouter(g)
		})
	fmt.Println("OutboundRegisterRouter err:", err)
}

func JobCenterRegisterRouter(g *gin.RouterGroup) {
	_ = di.InjectInstance().Invoke(func(ctl *job_center.JobCenterController) {
		ctl.RegisterRouter(g)
	})
}

func BackendRegisterRouters(g *gin.RouterGroup) {
	err := di.InjectInstance().Invoke(
		func(
			customerGroupController *backendBusinessOpportunity.CustomerGroupController,
			strategicMonitorController *backendBusinessOpportunity.StrategicMonitorGroupController,
			commonOptionController *backendCommon.OptionController,
			fileController *backendCommon.FileController,
			tenantController *backendCommon.TenantController,
			announcementController *backendCommon.SiteAnnouncementController,
			marketController *backendMarket.BackendOutboundTaskController,
		) {
			customerGroupController.RegisterRouter(g)
			strategicMonitorController.RegisterRouter(g)
			commonOptionController.RegisterRouter(g)
			fileController.RegisterRouter(g)
			tenantController.RegisterRouter(g)
			announcementController.RegisterRouter(g)
			marketController.RegisterRouter(g)
		})
	fmt.Println("BackendRegisterRouter err:", err)
}
